home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume4 / termlist < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  11.8 KB

  1. Path: xanth!mcnc!rutgers!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery
  2. From: geoff@p.UUCP (Geoff Leach)
  3. Newsgroups: comp.sources.misc
  4. Subject: v04i017: termlist: a perl program to print termcap entries
  5. Message-ID: <8808081802.AA21532@pyramid.pyramid.com>
  6. Date: 7 Aug 88 16:43:00 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: geoff@p.UUCP (Geoff Leach)
  9. Lines: 405
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. Posting-number: Volume 4, Issue 17
  13. Submitted-by: "Geoff Leach" <geoff@p.UUCP>
  14. Archive-name: termlist
  15.  
  16. Termlist is a perl program that produces an annotated listing of
  17. termcap file entries.  The output is (to the author, at least) more
  18. comprehensible than the standard termcap entry.
  19.  
  20. Thanks to Larry Wall for making it possible!
  21. --- Attached File ---
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then unpack
  24. # it by saving it into a file and typing "sh file".  To overwrite existing
  25. # files, type "sh file -c".  You can also feed this as standard input via
  26. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  27. # will see the following message at the end:
  28. #        "End of shell archive."
  29. # Contents:  README termlist termlist.pl
  30. # Wrapped by geoff@laticorp on Sun Aug  7 12:13:06 1988
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'README' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'README'\"
  34. else
  35. echo shar: Extracting \"'README'\" \(753 characters\)
  36. sed "s/^X//" >'README' <<'END_OF_FILE'
  37. X    Termlist.pl is a perl program that reads selected entries 
  38. X    (or all entries) from a termcap file and prints a sorted,
  39. X    annotated list of the entries, one per line.  The annotations
  40. X    file may be augmented to reflect capabilities in local use.
  41. X    The termlist file has one entry per line:
  42. X        capability <tab> description
  43. X    Limes beginning with a "#" are ignored.  There is no line
  44. X    continuation.
  45. X
  46. X    There are two paths in termlist.pl, /usr/local/bin/perl
  47. X    and /usr/local/lib/termlist.  
  48. X
  49. X    To install, simply copy termlist to /usr/local/lib and 
  50. X    termlist.pl to /usr/local/bin, or whereever you prefer.
  51. X
  52. X    To run: termlist.pl < termcap_file [entries].  If [entries] is
  53. X    empty, the entire termcap_file is printed.
  54. X
  55. X    Termlist was developed under perl version 2.0
  56. END_OF_FILE
  57. if test 753 -ne `wc -c <'README'`; then
  58.     echo shar: \"'README'\" unpacked with wrong size!
  59. fi
  60. # end of 'README'
  61. fi
  62. if test -f 'termlist' -a "${1}" != "-c" ; then 
  63.   echo shar: Will not clobber existing file \"'termlist'\"
  64. else
  65. echo shar: Extracting \"'termlist'\" \(5448 characters\)
  66. sed "s/^X//" >'termlist' <<'END_OF_FILE'
  67. X#    Sources
  68. X#        Termcap Reference Manual:
  69. X#        D. R. Merritt, Inter'l Technical Seminars, San Francisco CA
  70. X#        Termcap:
  71. X#        R. M. Stallman, Free Software Foundation, Cambridge MA
  72. X#        Termcap(5)
  73. X#        BSC 4.2 distribution termcap(5)
  74. X#        BSC 4.3 distribution termcap(5)
  75. X#        Sun OS 3.4 termcap(5)
  76. Xae    end alternate character set
  77. Xal    add blank line before cursor
  78. XAL    add 'n' blank lines before cursor
  79. Xam    auto margin
  80. Xas    start alternate character set
  81. Xbc    backspace character
  82. Xbl    bell
  83. Xbs    backspace
  84. Xbt    backtab
  85. Xbw    backspace wraps
  86. XCC    command character in prototype
  87. Xcd    clear to end of display
  88. Xce    clear to end of line
  89. Xch    cursor horizontal
  90. Xcl    clear screen
  91. Xcm    cursor motion
  92. XCM    cursor motion, relative to memory display
  93. Xco    number of columns
  94. Xcr    carriage return
  95. Xcs    change scroll
  96. XcS    change scroll (alternate form)
  97. XCs    default command in menu line (Contest DOS color)
  98. Xct    clear all tab stops
  99. Xcv    cursor vertical
  100. Xda    display retained above
  101. Xdb    display retained below
  102. XdB    delay for backspace
  103. Xdc    delete character
  104. XdC    delay for carriage
  105. XdF    delay for formfeed
  106. Xdl    delete line
  107. XDL    delete 'n' lines sarting at cursor
  108. Xdm    delete mode
  109. XdN    delay for newline
  110. Xdo    down line
  111. XDO    move cursor vertically down 'n' lilnes
  112. Xds    disable display of status line
  113. XdT    delay for tab
  114. Xec    clear 'n' characters at cursor
  115. Xed    end delete mode
  116. Xei    erases oversrike
  117. Xeo    output of space ends overstrike
  118. XEP    even parity
  119. Xes    other display commands work while writing status line
  120. Xff    formfeed
  121. Xfs    move cursor into status line
  122. Xgn    terminal type is generic
  123. Xhc    hardcopy
  124. Xhd    half line down
  125. XHD    half duplex
  126. Xho    cursor home
  127. Xhs    terminal has status line
  128. Xhu    half line up
  129. Xhz    terminal cannot accept '~' as output
  130. Xi1    initialize terminal for each login session (terminfo)
  131. Xi2    initialize terminal for each login session (terminfo)
  132. Xi3    initialize terminal for each login session (terminfo)
  133. Xic    insert characer
  134. XIC    insert 'n' characters at cursor
  135. Xif    initialization file
  136. Xim    insert mode
  137. Xin    inserts null
  138. Xip    insert pad
  139. XiP    pathname of initialization program (terminfo)
  140. Xis    initialization string
  141. Xit    initial spacing between hardware tab stops
  142. Xk0    keypad 0 (or 10)
  143. Xk1    keypad 1
  144. Xk2    keypad 2
  145. Xk3    keypad 3
  146. Xk4    keypad 4
  147. Xk5    keypad 5
  148. Xk6    keypad 6
  149. Xk7    keypad 7
  150. Xk8    keypad 8
  151. Xk9    keypad 9
  152. XK1    keypad upper left
  153. XK2    keypad upper right
  154. XK3    keypad center
  155. XK4    keypad lower left
  156. XK5    keypad lower right
  157. Xka    clear all tabs key
  158. XkA    insert line key
  159. Xkb    keypad backspace
  160. XkC    clear screen key
  161. Xkd    keypad down
  162. XkD    delete character key
  163. Xke    keypad end
  164. XkE    clear to end of line key
  165. XkF    scroll forward key
  166. Xkh    keypad home
  167. XkH    home down key
  168. XkI    insert character key
  169. Xki    keypad left
  170. XkL    delete line key
  171. Xkl    keypad left
  172. XkL    delete line key
  173. Xkm    terminal has meta key
  174. XkM    exit insert mode key
  175. Xkn    keypad number
  176. XkN    next page key
  177. Xko    non-function keys
  178. XkP    previous page key
  179. Xkr    keypad right
  180. XkR    scroll reverse key
  181. Xks    keypad start
  182. XkS    clear to end of screen key
  183. Xkt    clear tab stop this column key
  184. XkT    set tab stop this column
  185. Xku    keypad up
  186. Xkx    cancel command
  187. Xl0    label on "other" function key
  188. Xl1    label on "other" function key
  189. Xl2    label on "other" function key
  190. Xl3    label on "other" function key
  191. Xl4    label on "other" function key
  192. Xl5    label on "other" function key
  193. Xl6    label on "other" function key
  194. Xl7    label on "other" function key
  195. Xl8    label on "other" function key
  196. Xl9    label on "other" function key
  197. XLC    lower case only
  198. Xle    move cursor left one column
  199. XLE    move cursor left 'n' columns
  200. Xli    number of lines
  201. Xll    last line
  202. Xma    arrow key map
  203. Xmb    enter blinking mode
  204. Xmd    enter double-bright mode
  205. Xme    turn off all appearance modes
  206. Xmh    enter half-bright mode
  207. Xmi    move insert
  208. Xml    memory lock on move insert cursor
  209. Xmk    enter invisible mode
  210. Xmm    enable meta key
  211. Xmo    disable meta key
  212. Xmp    enter protected mode
  213. Xmr    enter reverse video mode
  214. Xms    move standout
  215. Xmu    memory unlock on move insert cursor
  216. Xnc    no carriage return
  217. Xnd    non-desructive space
  218. Xnl    new line
  219. Xns    no scrolling
  220. Xnv    move to next line (may clear remainder of current line)
  221. Xok    command completion
  222. XOP    odd parity
  223. Xos    overstrikes
  224. Xpb    lowest baud rate requiring padding
  225. Xpc    pad characer
  226. Xpf    terminate redirection to attached printer
  227. Xpk    program function key n to type string s (terminfo)
  228. Xpk    program function key n to execute string s (terminfo)
  229. Xpo    redirect output to printer
  230. XpO    redirect 'n' characters to printer
  231. Xps    print screen to attached printer
  232. Xpt    performs tab
  233. Xpx    program function key n to transmit string s (terminfo)
  234. Xr1    reset terminal to sane modes (terminfo)
  235. Xr2    reset terminal to sane modes (terminfo)
  236. Xr3    reset terminal to sane modes (terminfo)
  237. Xrc    move to saved cursor position
  238. Xrf    reset file (like if, but for reset(1))
  239. XRI    move cursor right 'n' columns
  240. Xrp    output character repeated 'n' times
  241. Xrs    reset terminal modes (like is, but fore reset(1))
  242. Xsa    turn on appearance modes
  243. Xsc    save cursos position
  244. Xse    standout end
  245. Xsf    scroll forwards
  246. XSF    scroll up 'n' lines
  247. Xsg    number of blank characters left by so or se
  248. Xso    standout
  249. Xsr    scroll down
  250. XSR    scroll down 'n' lines
  251. Xst    set tab stop at cursor
  252. Xta    tab
  253. Xtc    copy this entry
  254. Xte    termcap end
  255. Xti    termcap initialization
  256. Xts    move cursor to status line
  257. Xuc    underscore one character and move past it
  258. Xue    underscore end
  259. Xug    underscore garbage
  260. Xul    underline
  261. Xup    up line
  262. XUP    move cursor up 'n' lines
  263. Xus    underscore start
  264. Xvb    visual bell
  265. Xve    visual mode end
  266. Xvi    cursor invisible mode
  267. Xvs    visual mode start
  268. Xvt    virtual terminal number
  269. Xwi    set output screen window
  270. Xws    width of status line
  271. Xxb    Behive (f1 = ESC, f2 = ^C)
  272. Xxn    newline ignored after wrap (Concept)
  273. Xxr    return acts like \r\n (Delta Data)
  274. Xxs    standout not erased by writing over it (HP 264?)
  275. Xxt    tabs not destructive, magic so character (Teleray 1061)
  276. Xxx    Tektronix 4025 insert line
  277. END_OF_FILE
  278. if test 5448 -ne `wc -c <'termlist'`; then
  279.     echo shar: \"'termlist'\" unpacked with wrong size!
  280. fi
  281. # end of 'termlist'
  282. fi
  283. if test -f 'termlist.pl' -a "${1}" != "-c" ; then 
  284.   echo shar: Will not clobber existing file \"'termlist.pl'\"
  285. else
  286. echo shar: Extracting \"'termlist.pl'\" \(3196 characters\)
  287. sed "s/^X//" >'termlist.pl' <<'END_OF_FILE'
  288. X#!    /usr/local/bin/perl
  289. X
  290. X# Save the ARGV list; if non-null, its a list of term entryies
  291. X$args = $#ARGV + 1;
  292. Xwhile ( $ARGV[0] )
  293. X{
  294. X    $argv{$ARGV[0]} = 1;
  295. X    shift(@ARGV);
  296. X}
  297. X
  298. X# Process the list of known termcap identifiers and their description
  299. X
  300. Xopen(termlist, "/usr/local/lib/termlist");
  301. Xwhile (<termlist>)
  302. X{
  303. X    chop;
  304. X    @line = split(/\t/);
  305. X    $symbol_definitions{$line[0]} = $line[1] if !/^#/;
  306. X}
  307. Xclose(termlist);
  308. X
  309. X# process the termcap file presented on stdin
  310. X
  311. Xwhile ( <> )
  312. X{
  313. X    $comments = "";
  314. X    $namelist = "";
  315. X    # Dispose of the coments (if any)
  316. X    while ( /^#|^\n/ )
  317. X    {
  318. X    $comments .= length($_) <= 70 ? $_ : substr($_, 0, 70) . "...\n";
  319. X    $_ = <>;
  320. X    }
  321. X
  322. X    # Get the entire entry
  323. X    $entry = $_;
  324. X    do
  325. X    {
  326. X    $entry .= <>;
  327. X    } while substr($entry, length($entry)-2, 1) eq "\\";
  328. X
  329. X    # If the file had trailing comments we will have read a null entry
  330. X    exit if !$entry;
  331. X
  332. X    # Clear leading whitespace and (possibly escaped) newlines,
  333. X    # using the multiple line record matching feature.
  334. X    $* = 1; $entry =~ s/\t|^ +|\\\n|\n//g; $* = 0;
  335. X
  336. X    # Get the terminal names, delimited by "|", ended by ":"
  337. X    # and the capabilities, enclosed in one or more ":", being careful to 
  338. X    # avoid being confused by escaped colons and escaped backslashes at the
  339. X    # end of an entry.
  340. X    $entry =~ s/\\:/\\\001/g;
  341. X    $entry =~ s/\\\\/\\\002/g;
  342. X    @names = split(/:+/, $entry);
  343. X
  344. X    # Look for a particular terminal if any were specified.  Otherwise do all.
  345. X    $found = 0;
  346. X    foreach $name ( split(/\|/, $names[0]) )
  347. X    {
  348. X    $found |= $argv{$name};
  349. X    $namelist .= "    " . $name . "\n";
  350. X    }
  351. X
  352. X    # Loop to the next entry if a requested entry was not found.
  353. X    next if $args && !$found;
  354. X
  355. X    # Print that part of the entry which we've saved waiting to see if
  356. X    # the entry would be selected.
  357. X    print $comments, "Names for this terminal:\n", $namelist,
  358. X      "\nTerminal capabilities:\n";
  359. X
  360. X    # Discard the first of the names entry, which contains the terminal names.
  361. X    shift(@names);
  362. X
  363. X    # Clear the symbol tables
  364. X    @syms = ();
  365. X    @symtab = ();
  366. X
  367. X    # Translate some of the more obscure things in the capability definitions
  368. X    # to "readable" definitions.  The order of the first five is important.
  369. X    foreach $nam ( @names )
  370. X    {
  371. X    ($name, $value) = split(/=|#/, $nam);
  372. X    next if $name eq " ";
  373. X    $value =~ s/\\\^/^/g;
  374. X    $value =~ s/\\0x/0x/g;
  375. X    $value =~ s/\\\001/:/g;
  376. X    $value =~ s/\\\002/\\/g;
  377. X    $value =~ s/\\\\/\\/g;
  378. X    $value =~ s/\\b/<bs>/g;
  379. X    $value =~ s/\\f/<ff>/g;
  380. X    $value =~ s/\\n/<nl>/g;
  381. X    $value =~ s/\\E/<esc>/g;
  382. X    $value =~ s/\\1/01/g;
  383. X    $value =~ s/\\2/02/g;
  384. X    $value =~ s/\\3/03/g;
  385. X    $value =~ s/\\4/04/g;
  386. X    $value =~ s/\\5/05/g;
  387. X    $value =~ s/\\6/06/g;
  388. X    $value =~ s/\\7/07/g;
  389. X    $value =~ s/\\0/<nul>/g;
  390. X    $value =~ s/\\r/<ret>/g;
  391. X    $value =~ s/\\t/<tab>/g;
  392. X    $symtab{$name} = $value ? $value : "<set>";
  393. X    push(@syms, $name);
  394. X    }
  395. X    format stdout =
  396. X    @<<<<<<<  @<<<<<<<<<<<<<<<<<<<<   @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  397. X    $sym  $symtab_entry           $symbol_def 
  398. X.
  399. X    foreach $sym ( sort @syms )
  400. X    {
  401. X    $symtab_entry = $symtab{$sym};
  402. X    $symbol_def   = $symbol_definitions{$sym};
  403. X    $symbol_def   = "" if $symbol_def eq "0";
  404. X    write();
  405. X    }
  406. X    print "\f\n";
  407. X}
  408. END_OF_FILE
  409. if test 3196 -ne `wc -c <'termlist.pl'`; then
  410.     echo shar: \"'termlist.pl'\" unpacked with wrong size!
  411. fi
  412. chmod +x 'termlist.pl'
  413. # end of 'termlist.pl'
  414. fi
  415. echo shar: End of shell archive.
  416. exit 0
  417.